package com_djm_2025_06_09.myString.StringDemo;

/**
 *
 * 验证一个猜想：在不适用StringBuffer和StringBuilder的
 * 情况下改变字符串,在写博客的时候把这个代码画一下内存图？
 * @author dengjiangming
 * @date 2025-06-09
 * @version 1.0.0
 */
public class StringDemo2 {

    public static void main(String[] args) {
        String str = "abcdef";

        String str1 = "abcdef";

        System.out.println("修改前：");
        System.out.println(str);
        System.out.println(str1);
        System.out.println(str.hashCode());
        System.out.println(str1.hashCode());
        //一条华丽的分割线
        System.out.println("-----------------");

        //将字符串转化为字符数组
        char[] chars = str.toCharArray();

        chars[1] = 'B';

//        str = new String(chars);
        str = String.valueOf(chars);
        System.out.println(str);
        System.out.println(str1);
        System.out.println(str.hashCode());
        System.out.println(str1.hashCode());


    }

}
